package trial.stream;

import org.junit.jupiter.api.Test;

import java.util.Optional;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * 改进的Stream API
 */
public class BetterStream {
    @Test
    public void printOneToTen() {
        // 更简短的for循环，输出1到10
        IntStream.iterate(1, i -> i <= 10, i -> i + 1).forEach(System.out::println);
    }

    @Test
    public void optionalToStream() {
        // Optional可以方便地转换成为Stream
        Stream<Integer> stream = Optional.of(1).stream();
    }
}
